package com.ruoyi.example.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.example.mapper.GatewayMapper;
import com.ruoyi.example.domain.Gateway;
import com.ruoyi.example.service.IGatewayService;

import javax.annotation.Resource;

/**
 * 物联网关信息Service业务层处理
 *
 * @author ruoyi
 * @date 2023-04-10
 */
@Service
public class GatewayServiceImpl implements IGatewayService {
    @Resource
    private GatewayMapper gatewayMapper;

    /**
     * 查询物联网关信息
     *
     * @param id 物联网关信息主键
     * @return 物联网关信息
     */
    @Override
    public Gateway selectGatewayById(Long id) {
        return gatewayMapper.selectGatewayById(id);
    }

    /**
     * 查询物联网关信息列表
     *
     * @param gateway 物联网关信息
     * @return 物联网关信息
     */
    @Override
    public List<Gateway> selectGatewayList(Gateway gateway) {
        return gatewayMapper.selectGatewayList(gateway);
    }

    /**
     * 新增物联网关信息
     *
     * @param gateway 物联网关信息
     * @return 结果
     */
    @Override
    public int insertGateway(Gateway gateway) {
        gateway.setCreateBy(SecurityUtils.getUsername());
        gateway.setCreateTime(DateUtils.getNowDate());
        return gatewayMapper.insertGateway(gateway);
    }

    /**
     * 修改物联网关信息
     *
     * @param gateway 物联网关信息
     * @return 结果
     */
    @Override
    public int updateGateway(Gateway gateway) {
        gateway.setUpdateBy(SecurityUtils.getUsername());
        gateway.setUpdateTime(DateUtils.getNowDate());
        return gatewayMapper.updateGateway(gateway);
    }

    /**
     * 批量删除物联网关信息
     *
     * @param ids 需要删除的物联网关信息主键
     * @return 结果
     */
    @Override
    public int deleteGatewayByIds(Long[] ids) {
        return gatewayMapper.deleteGatewayByIds(ids);
    }

    /**
     * 删除物联网关信息信息
     *
     * @param id 物联网关信息主键
     * @return 结果
     */
    @Override
    public int deleteGatewayById(Long id) {
        return gatewayMapper.deleteGatewayById(id);
    }
}
